package javat.lang;

import static net.ftng.commons.lang.utils.PrintUtils.println;
import static org.junit.Assert.assertEquals;

import java.io.UnsupportedEncodingException;

import net.ftng.commons.lang.utils.StringUtils;

import org.junit.Test;

public class StringTest {

    public static void main(final String[] args) throws UnsupportedEncodingException {

        // Encoding
        String test = "你好";
        byte[] utf8Bytes = test.getBytes();
        String utf8String = new String(utf8Bytes, "utf-8");
        println(utf8String);
        byte[] gbkBytes = test.getBytes();
        String gbkString = new String(gbkBytes, "gbk");
        println(gbkString);
        String utf8String1 = StringUtils.encoding(gbkString, "gbk", "utf-8");
        println(utf8String1);
    }

    @Test
    public void split() {

        String testString = "hello world!";
        String[] strings = testString.split(" ");
        String expected = "hello";
        assertEquals(expected, strings[0]);
        expected = "world!";
        assertEquals(expected, strings[1]);
    }

}
